#!/bin/bash
set -eu
# This is a backwards compatibility script. All logic has moved to '@aws-cdk-testing/cli-integ'
# and should be called from there directly.

export VERSION=$(node -pe "require('./build.json').version")

# The package MUST be 'npm install'ed from the package repository (`npm install --production`
# will not work because that will resolve devDependencies even though it will not install them),
# but it may not live in a 'node_modules' directory because Jest 27 does not support that. Do contortions.
export INTEG_TOOLS=cli_integ
rm -rf $INTEG_TOOLS && mkdir $INTEG_TOOLS
npm install --prefix $INTEG_TOOLS --no-save ./js/aws-cdk-testing-cli-integ-*.tgz
mv $($INTEG_TOOLS/node_modules/.bin/test-root)/* $INTEG_TOOLS

# Do a breakpoint for testing
codebuild-breakpoint

CONCURRENCY=5 exec ${INTEG_TOOLS}/bin/stage-distribution run . "$@"
